#include <config.h>
#include <common.h>
#include <command.h>
#include <asm/io.h>
#include <asm/arch/platform.h>
int mygpio(void)
{
#if (defined CONFIG_AUTO_SD_UPDATE) || (defined CONFIG_AUTO_USB_UPDATE)
	/* to add some judgement if neccessary */
	unsigned int  val[3];

	writel(REG_BASE_GPIO0 + GPIO_DIR_OFST, 0);

	val[0] = readl(REG_BASE_GPIO0 + GPIO0_0_DATA_OFST);
	if(val[0])
		return 0;

	udelay(10000);
	val[1] = readl(REG_BASE_GPIO0 + GPIO0_0_DATA_OFST);
	udelay(10000);
	val[2] = readl(REG_BASE_GPIO0 + GPIO0_0_DATA_OFST);
	udelay(10000);

	if (val[0] == val[1] && val[1] == val[2] && val[0] == 0)
		return 1;/* update enable */
	else
		return 0;

#else
	return 0;
#endif
}

static int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
    printf("Led test start\n");
    mygpio();
    return 0;
}


U_BOOT_CMD(
		led,	3,	1,	do_led,
		"led test command",
		"led test command"
	  );
